﻿<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin_model extends CI_Model {
		
	public function __constructor()
	{  
	    parent::Model();  
	}
	
	function check_id($email,$password)
	{
		$this->db->where('user_email',$email);
		$this->db->where('user_password',$password);
		$q = $this->db->get('admin_user_login');
		if ($q->num_rows()>0) 
		{
			return TRUE;
		}
		else {
			return false;
		}
	}
	
	function list_user()
	{	
		//$this->db->order_by('landing_mail','asc'); // optional
		$query =  $this->db->get('landing_user');
		$this->row_count = $query->num_rows();
		if($query->num_rows() > 0)
		{
			foreach($query->result() as $row)
			{
				$data[] = $row;
			}
		return $data;
		}
	}
	
	function get_user_edit($id)
	{
		$this->db->where('id_login',$id);
		$q = $this->db->get('land_user_login');
		if ($q->num_rows()>0) 
		{
			$row = $q->row();
			return $row;
		}
		
	}
	
	function home_slider()
	{	
		//$this->db->order_by('landing_mail','asc'); // optional
		$query =  $this->db->get('home_slider');
		$this->row_count = $query->num_rows();
		if($query->num_rows() > 0)
		{
			foreach($query->result() as $row)
			{
				$data[] = $row;
			}
		return $data;
		}
	}
	
	function list_update_slider($id)
	{
		$this->db->where('id_slider',$id);
		$query =  $this->db->get('home_slider');
		if($query->num_rows() > 0)
		{			
			$row = $query->row();
			return $row;
		}
	}
	
	function list_update_about($id)
	{
		$this->db->where('id_about',$id);
		$query =  $this->db->get('home_about');
		if($query->num_rows() > 0)
		{			
			$row = $query->row();
			return $row;
		}
	}
	

	function update_slider($id,$data)
	{
		$this->db->where('id_slider',$id);
		$this->db->update('home_slider',$data);	
	}
	
	
	function delete_slider($id)
	{
		$this->db->where('id_slider',$id);
		$this->db->delete('home_slider');
	}
	
	function get_slider($id)
	{
		$this->db->where('id_slider',$id);
		$query =  $this->db->get('home_slider');
		if($query->num_rows() > 0)
		{
			$row = $query->row();
			return $row;
		}
	}

	function get_partenaires($id)
	{
		$this->db->where('id_partenaires',$id);
		$query =  $this->db->get('home_partenaires');
		if($query->num_rows() > 0)
		{
			$row = $query->row();
			return $row;
		}
	}

	function update_partenaires($id,$data)
	{
		$this->db->where('id_partenaires',$id);
		$this->db->update('home_partenaires',$data);	
	}

	function get_produits($id)
	{
		$this->db->where('id_produits',$id);
		$query =  $this->db->get('home_produits');
		if($query->num_rows() > 0)
		{
			$row = $query->row();
			return $row;
		}
	}

	function update_produits($id,$data)
	{
		$this->db->where('id_produits',$id);
		$this->db->update('home_produits',$data);	
	}


	function home_about()
	{	
		//$this->db->order_by('landing_mail','asc'); // optional
		$query =  $this->db->get('home_about');
		$this->row_count = $query->num_rows();
		if($query->num_rows() > 0)
		{
			foreach($query->result() as $row)
			{
				$data[] = $row;
			}
		return $data;
		}
	}

	function add_slider($data)
	{
		echo $this->db->insert('home_slider',$data);
	}
	
	function check_email($data)
	{
		$this->db->where('user_email',$data);
		$q = $this->db->get('land_user_login');
		if ($q->num_rows()>0) 
		{
			return TRUE;
		}
	}

	function home_service()
	{	
		//$this->db->order_by('landing_mail','asc'); // optional
		$query =  $this->db->get('home_produits_service');
		$this->row_count = $query->num_rows();
		if($query->num_rows() > 0)
		{
			foreach($query->result() as $row)
			{
				$data[] = $row;
			}
		return $data;
		}
	}
	
	function list_update_service($id)
	{
		$this->db->order_by('id_service','asc'); 	
		$this->db->where('id_service',$id);
		$query =  $this->db->get('home_produits_service');
		if($query->num_rows() > 0)
		{			
			$row = $query->row();
			return $row;
		}
	}
	function add_user($data)
	{
		$this->db->insert('land_user_login',$data);
	}

	function send_message($data)
	{
		$this->db->insert('contact_infos',$data);
	}

	function list_message()
	{	
		$this->db->order_by('id_contact_infos','desc'); // optional
		$query =  $this->db->get('contact_infos');
		$this->row_count = $query->num_rows();
		if($query->num_rows() > 0)
		{
			foreach($query->result() as $row)
			{
				$data[] = $row;
			}
		return $data;
		}
	}

	function get_message($id)
	{
		$this->db->where('id_contact_infos',$id);
		$q = $this->db->get('contact_infos');
		if ($q->num_rows()>0)
		{
			$row = $q->row();
			return $row;
		}
		
	}

	function update_message($id,$data)
	{
		$this->db->where('id_contact_infos',$id);
		$this->db->update('contact_infos',$data);	
	}
	
	function add_partenaires($data)
	{
		echo $this->db->insert('home_partenaires',$data);
	}

	function add_produits($data)
	{
		echo $this->db->insert('home_produits',$data);
	}
	
	
}
?>